<?php
require_once '../model/conn.php';
require_once '../model/artCom.php';
header('Content-Type: application/json');

$aid = isset($_POST['aid']) ? intval($_POST['aid']) : 0;
$sql = "select * from tbl_user where uname ='$_POST[uname]';";
$uid = intval(exec_select($sql)[0]['uid']);
$content = $_POST['content'];
$cid = insertCom($aid, $uid, $content);


if ($aid <= 0) {
  echo json_encode(['code' => 500, 'msg' => '请求出错']);
  exit;
}
if ($cid > 0) {
  echo json_encode(['code' => 200, 'msg' => '评论成功', 'cid' => $cid, 'whoid' => $uid]);
  exit;
} else {
  echo json_encode(['code' => 500, 'msg' => '评论失败']);
  exit;
}


?>